package com.zjy.heath_ms.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mysql.jdbc.StringUtils;
import com.zjy.heath_ms.entity.QueryPageBean;
import com.zjy.heath_ms.mapper.OrderMapper;
import com.zjy.heath_ms.pojo.Order;
import com.zjy.heath_ms.service.OrderService;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * 项目名 heath_ms
 * 类名  OrderServiceImpl
 * 作者 lzq
 * 创建时间  2025/5/25 9:45
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
    @Override
    public Page<Order> findPage(QueryPageBean queryPageBean) {

        HashMap<String, Object> queryCondition = new HashMap<>();
        String queryString = queryPageBean.getQueryString();
        if (!StringUtils.isNullOrEmpty(queryString)) {
            queryCondition.put("fileNumber", queryString);
            queryCondition.put("name", queryString);
            queryCondition.put("phoneNumber", queryString);
        }

        Page<Order> orderPage = new Page<>(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        baseMapper.selectDetailPage(orderPage, queryCondition);
        return orderPage;
    }

    @Override
    public boolean hasVisit(Integer id) {
        Order order = new Order();
        order.setId(id);
        order.setOrderStatus(Order.ORDERSTATUS_YES);
        int res = baseMapper.updateById(order);
        return res > 0;
    }
}
